package duilibhx.ui;
import cpp.Lib;
import duilibhx.events.Event;

/**
 * ...
 * @author wangjian QQ:421924396
 */

class Control extends UIBase 
{
	//public var onInit:Dynamic;
	//public var onDestroy:Dynamic;
	//public var onSize:Dynamic;
	//public var onEvent:Dynamic;
	//public var onNotify:Dynamic;
	private var notifyCallBack:Notify->Bool;
	private var isHasNofity:Bool;
	private function new(_dui_handle:Dynamic) 
	{
		super(_dui_handle);
		isHasNofity = false;
	}
	public function getName():String {
		return dui_control_getname(duilib_handle);
	}
	public function setName(name:String):Void {
		
	}
	/**
	 * 文本相关
	 */
	
	public function getText():String {
		return "";
	}
	
	public function setText(_txt:String) {
		
	}
	
	/*图形相关*/
	public function getBkColor():Void {
		
	}
	public function addNotify(handle:Notify->Bool):Void {
		if (isHasNofity==false) { //注册notify
			dui_control_onnotify(duilib_handle);
			isHasNofity = true;
		}
		notifyCallBack = handle;
	}
	public function removeNotify():Void {
		notifyCallBack = null;
		//todo 移去侦听
		//isHasNofity = false;
	}
	private  function onNotify(event:Notify):Bool {
		//event.sender = this;
		return notifyCallBack(event);
	}
	static var dui_control_onnotify = Lib.load("DuiLib", "dui_control_onnotify", 1);
	static var dui_control_getname = Lib.load("DuiLib", "dui_control_getname", 1);
	static var dui_cpp_control_getname = Lib.load("DuiLib", "dui_cpp_control_getname", 1);
	//GetBkImage
	//SetBkImage
	//GetBorderColor
	//SetBorderColor
	//GetFocusBorderColor
	//SetFocusBorderColor
	//IsColorHSL
	//SetColorHSL
	//GetBorderSize
	//SetBorderSize
	//GetBorderRound
	//SetBorderRound
	//DrawImage
	
	/*位置相关*/
	 //virtual const RECT& GetPos() const;
    //virtual void SetPos(RECT rc);
    //virtual int GetWidth() const;
    //virtual int GetHeight() const;
    //virtual int GetX() const;
    //virtual int GetY() const;
    //virtual RECT GetPadding() const;
    //virtual void SetPadding(RECT rcPadding); // 设置外边距，由上层窗口绘制
    //virtual SIZE GetFixedXY() const;         // 实际大小位置使用GetPos获取，这里得到的是预设的参考值
    //virtual void SetFixedXY(SIZE szXY);      // 仅float为true时有效
    //virtual int GetFixedWidth() const;       // 实际大小位置使用GetPos获取，这里得到的是预设的参考值
    //virtual void SetFixedWidth(int cx);      // 预设的参考值
    //virtual int GetFixedHeight() const;      // 实际大小位置使用GetPos获取，这里得到的是预设的参考值
    //virtual void SetFixedHeight(int cy);     // 预设的参考值
    //virtual int GetMinWidth() const;
    //virtual void SetMinWidth(int cx);
    //virtual int GetMaxWidth() const;
    //virtual void SetMaxWidth(int cx);
    //virtual int GetMinHeight() const;
    //virtual void SetMinHeight(int cy);
    //virtual int GetMaxHeight() const;
    //virtual void SetMaxHeight(int cy);
    //virtual void SetRelativePos(SIZE szMove,SIZE szZoom);
    //virtual void SetRelativeParentSize(SIZE sz);
    //virtual TRelativePosUI GetRelativePos() const;
    //virtual bool IsRelativePos() const;
//
    // 鼠标提示
    //virtual CStdString GetToolTip() const;
    //virtual void SetToolTip(LPCTSTR pstrText);
//
    // 快捷键
    //virtual TCHAR GetShortcut() const;
    //virtual void SetShortcut(TCHAR ch);
//
    // 菜单
    //virtual bool IsContextMenuUsed() const;
    //virtual void SetContextMenuUsed(bool bMenuUsed);
//
    // 用户属性
    //virtual const CStdString& GetUserData(); // 辅助函数，供用户使用
    //virtual void SetUserData(LPCTSTR pstrText); // 辅助函数，供用户使用
    //virtual UINT_PTR GetTag() const; // 辅助函数，供用户使用
    //virtual void SetTag(UINT_PTR pTag); // 辅助函数，供用户使用
//
    // 一些重要的属性
    //virtual bool IsVisible() const;
    //virtual void SetVisible(bool bVisible = true);
    //virtual void SetInternVisible(bool bVisible = true); // 仅供内部调用，有些UI拥有窗口句柄，需要重写此函数
    //virtual bool IsEnabled() const;
    //virtual void SetEnabled(bool bEnable = true);
    //virtual bool IsMouseEnabled() const;
    //virtual void SetMouseEnabled(bool bEnable = true);
    //virtual bool IsKeyboardEnabled() const;
    //virtual void SetKeyboardEnabled(bool bEnable = true);
    //virtual bool IsFocused() const;
    //virtual void SetFocus();
    //virtual bool IsFloat() const;
    //virtual void SetFloat(bool bFloat = true);
//
    //virtual CControlUI* FindControl(FINDCONTROLPROC Proc, LPVOID pData, UINT uFlags);
//
    //void Invalidate();
    //bool IsUpdateNeeded() const;
    //void NeedUpdate();
    //void NeedParentUpdate();
    //DWORD GetAdjustColor(DWORD dwColor);
//
    //virtual void Init();
    //virtual void DoInit();
//
    //virtual void Event(TEventUI& event);
    //virtual void DoEvent(TEventUI& event);
//
    //virtual void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
    //CControlUI* ApplyAttributeList(LPCTSTR pstrList);
//
    //virtual SIZE EstimateSize(SIZE szAvailable);
//
    //virtual void DoPaint(HDC hDC, const RECT& rcPaint);
    //virtual void PaintBkColor(HDC hDC);
    //virtual void PaintBkImage(HDC hDC);
    //virtual void PaintStatusImage(HDC hDC);
    //virtual void PaintText(HDC hDC);
    //virtual void PaintBorder(HDC hDC);
//
    //virtual void DoPostPaint(HDC hDC, const RECT& rcPaint);
//
//public:
    //CEventSource OnInit;
    //CEventSource OnDestroy;
    //CEventSource OnSize;
    //CEventSource OnEvent;
    //CEventSource OnNotify;
	
	
}